package com.hc.dao;

import com.hc.bean.OrderDetail;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface OrderDetailDao {
    /*根据id查询订单信息*/
    @Select("select * from order_detail where oid=#{oid}")
    @Results({
            @Result(column = "pid",property = "pid"),
            @Result(column = "pid",property = "productInfo",one = @One(select = "com.hc.dao.ProductInfoDao.getProductInfoByPid"))
    })
    public List<OrderDetail> getOrderDetailByOrderId(int oid);

    /*添加订单明细*/
    @Insert("insert into order_detail values(#{id},#{oid},#{pid},#{num})")
    public int addOrderDetail(OrderDetail orderDetail);

    /*删除订单明细*/
    /*依赖版本太低时候,且需要使用$时,需要加上@Param()命名空间*/
    /*在不使用@Param注解的时候，在查询语句取值时只能用#{}，所属的类必须为Javabean*/
    @Delete("delete  from order_detail where oid in (${oids})")
    public int deleteOrderDetailByOid(String oids);
}
